package com.sunchangpeng.server.bio.pool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class TimeServerHandlerExecutePool {
    private ExecutorService executor;

    public TimeServerHandlerExecutePool(int maxPoolSize, int queueSize) {
        int availableProcessors = Runtime.getRuntime().availableProcessors();
        ArrayBlockingQueue queue = new ArrayBlockingQueue(queueSize);
        this.executor = new ThreadPoolExecutor(availableProcessors, maxPoolSize, 120L, TimeUnit.SECONDS, queue);
    }

    public void execute(Runnable task) {
        this.executor.execute(task);
    }
}
